home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Sample Code / Display Manager / Display Manager Sample Code / DMFkey Source / DMFkey.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-06-24  |  2.9 KB  |  93 lines  |  [TEXT/CWIE]

  1. /*—————————————————————————————————————————————————————————————————————————————————————
  2. #
  3. #    Display Flip FKey 1.0.
  4. #    
  5. #    Written by: Eric Anderson
  6. #     email: eric3@apple.com
  7. #
  8. #    Display Manager sample code using FKey
  9. #
  10. #    • Display Flip FKEY=0
  11. #
  12. #    DMFkey.c    -    C Code
  13. #
  14. #    Copyright © 1996 Eric3 Anderson
  15. #    Free to distribute, modify, fold, spindle, and mutilate. Whatever.
  16. #
  17. #    2/10/96        ewa        New today.
  18. #
  19. #
  20. #
  21. #    Components:    DMFkey.c            
  22. #                RequestVideo.c        
  23. #                RequestVideo.h        
  24. #
  25. #    Uses the kool new Display Manager 2.0 (found in System 7.5.2 and later, or in
  26. #    the version 2.0 Display Enabler system extension which ships with the new
  27. #    AppleVision multisync displays) to change the monitor screen resolution
  28. #    the specified HxV resolutions.
  29. #
  30. #    This FKey will flip between 640x480 and BIG.
  31. #    BIG is up to 2000x2000 if your monitor supports it.
  32. #
  33. #    For information on the use of the RequestVideo sample code, please refer to the
  34. #    documentation found in the Display Manager Development Kit, or just look at the 
  35. #    code and comments to figure it out.
  36. —————————————————————————————————————————————————————————————————————————————————————*/
  37.  
  38. #define minHorizontalRequest        640
  39. #define minVerticalRequest            480
  40.  
  41. #define maxHorizontalRequest        2000
  42. #define maxVerticalRequest            2000
  43.  
  44. #define bitDepthRequest                32
  45.  
  46. #include <Types.h>
  47. #include <Quickdraw.h>
  48.  
  49. #include "RequestVideo.h"                    // The code that does the real work
  50.  
  51. struct INITGlobals {
  52.     QDGlobals        initQDGlobals;            // FKEY's own private QDGlobals
  53.     unsigned long    initQDBase;                // FKEY's global base
  54. };
  55. typedef struct INITGlobals INITGlobals;
  56.  
  57. main()
  58. {
  59.     VideoRequestRec    requestRec;
  60.     INITGlobals        qdGlobs;
  61.     long            oldA5;
  62.     unsigned long    theHorizontalRequest;
  63.     unsigned long    theVerticalRequest;        
  64.     
  65.     oldA5 = SetA5((long) &qdGlobs.initQDBase);
  66.     InitGraf((Ptr) &qdGlobs.initQDGlobals.thePort);
  67.     
  68.     theHorizontalRequest = minHorizontalRequest;
  69.     theVerticalRequest = minVerticalRequest;
  70.  
  71.     requestRec.screenDevice = GetMainDevice ();
  72.     requestRec.reqHorizontal = (*(*(requestRec.screenDevice))->gdPMap)->bounds.right;    // main screen is always zero offset (bounds.left == 0)
  73.     requestRec.reqVertical = (*(*(requestRec.screenDevice))->gdPMap)->bounds.bottom;    // main screen is always zero offset (bounds.top == 0)
  74.      if (requestRec.reqHorizontal == minHorizontalRequest || requestRec.reqVertical == minVerticalRequest)    // on a small screen now?
  75.      {
  76.          theHorizontalRequest    =    maxHorizontalRequest;
  77.          theVerticalRequest        =    maxVerticalRequest;
  78.      }
  79.  
  80.     requestRec.reqBitDepth        =    bitDepthRequest;        // bit depth request
  81.     requestRec.reqHorizontal    =    theHorizontalRequest;    // H request
  82.     requestRec.reqVertical        =    theVerticalRequest;        // V request
  83.     requestRec.displayMode        =    nil;                    // must init to nil
  84.     requestRec.depthMode        =    nil;                    // must init to nil
  85.     requestRec.requestFlags        =    0;                        
  86.     if (noErr == RVRequestVideoSetting(&requestRec))
  87.     {
  88.         RVSetVideoRequest (&requestRec);
  89.     }
  90.     SetA5(oldA5);
  91.     return (noErr);
  92. }
  93.